home *** CD-ROM | disk | FTP | other *** search
- RCS_ID_C "$Id: iconify.c,v 1.3 1991/11/14 07:20:38 ptp Exp $";
- /* This code has been highly modified for use in niftyterm. Thanks
- * to Leo Schwab for the nice example code.
- * -- Todd Williamson, 12-14-89
- *
- * $Author: ptp $ $Revision: 1.3 $ $Date: 1991/11/14 07:20:38 $
- */
-
- #include "amiga.h"
-
- /*
- *
- * iconify.c: You asked for it, you got it.
- *
- * Copyright 1987 by Leo L. Schwab.
- * Permission is hereby granted for use in any and all programs, both
- * Public Domain and commercial in nature, provided this Copyright notice
- * is left intact. Purveyors of programs, at their option, may wish observe
- * the following conditions (in the spirit of hackerdom):
- * 1: You send me a free, registered copy of the program that uses the
- * iconify feature,
- * 2: If you're feeling really nice, a mention in the program's
- * documentation of my name would be neat.
- *
- * 8712.10 (415) 456-3960
- */
-
- UWORD icon_data[6 * 18 * 2] = {
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x3fff,0xffff,0xffff,0xffff,0xffff,0xffc0,
- 0x3fff,0xffff,0xffff,0xffff,0xffff,0xffc0,
- 0x3800,0x0000,0x0000,0x0000,0x0000,0x01c0,
- 0x3800,0x0000,0x0000,0x0000,0x0000,0x01c0,
- 0x3831,0x8607,0x0200,0x0200,0x0000,0x01c0,
- 0x3839,0x800d,0x8600,0x0600,0x0000,0x01c0,
- 0x383d,0x8e0c,0x0f99,0x8f8f,0x3b19,0x81c0,
- 0x3837,0x861e,0x0619,0x8619,0x9d9d,0xc1c0,
- 0x3833,0x860c,0x0619,0x861f,0x999a,0xc1c0,
- 0x3831,0x860c,0x068f,0x0698,0x1818,0xc1c0,
- 0x3831,0x8f1e,0x0306,0x030f,0x3c18,0xc1c0,
- 0x3800,0x0000,0x001c,0x0000,0x0000,0x01c0,
- 0x3800,0x0000,0x0000,0x0000,0x0000,0x01c0,
- 0x3800,0x0000,0x0000,0x0000,0x0000,0x01c0,
- 0x3fff,0xffff,0xffff,0xffff,0xffff,0xffc0,
- 0x3fff,0xffff,0xffff,0xffff,0xffff,0xffc0,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0xffff,0xffff,0xffff,0xffff,0xffff,0xfff0,
- 0xffff,0xffff,0xffff,0xffff,0xffff,0xfff0,
- 0xf000,0x0000,0x0000,0x0000,0x0000,0x00f0,
- 0xf000,0x0000,0x0000,0x0000,0x0000,0x00f0,
- 0xf000,0x0000,0x0000,0x0000,0x0000,0x00f0,
- 0xf000,0x0000,0x0000,0x0000,0x0000,0x00f0,
- 0xf000,0x0000,0x0000,0x0000,0x0000,0x00f0,
- 0xf000,0x0000,0x0000,0x0000,0x0000,0x00f0,
- 0xf000,0x0000,0x0000,0x0000,0x0000,0x00f0,
- 0xf000,0x0000,0x0000,0x0000,0x0000,0x00f0,
- 0xf000,0x0000,0x0000,0x0000,0x0000,0x00f0,
- 0xf000,0x0000,0x0000,0x0000,0x0000,0x00f0,
- 0xf000,0x0000,0x0000,0x0000,0x0000,0x00f0,
- 0xf000,0x0000,0x0000,0x0000,0x0000,0x00f0,
- 0xf000,0x0000,0x0000,0x0000,0x0000,0x00f0,
- 0xf000,0x0000,0x0000,0x0000,0x0000,0x00f0,
- 0xffff,0xffff,0xffff,0xffff,0xffff,0xfff0,
- 0xffff,0xffff,0xffff,0xffff,0xffff,0xfff0,
- };
-
- struct Image icon = {
- 0, 0, 92, 18, 2, &icon_data[0], 3, 0, NULL
- };
-
- UWORD *chipbitmap=NULL;
- struct Image *chipimg=NULL;
-
- /*
- * Jim Mackraz suggested making icons easily identifiable by outside
- * programs, so this constant gets stuffed into the UserData field.
- */
- #define ICON 0x49434f4eL /* 'ICON' */
-
- static struct Gadget gadget = {
- NULL,
- 0, 0, 0, 0,
- NULL, /* Set later */
- GADGIMMEDIATE,
- WDRAGGING, /* Observe the Magic! */
- NULL, /* Set later */
- NULL, NULL, NULL, NULL,
- 0, 0
- };
-
- static struct NewWindow windef = {
- 0, 0, 0, 0, /* Set later */
- -1, -1,
- GADGETDOWN,
- SMART_REFRESH | NOCAREREFRESH,
- &gadget,
- NULL, NULL, NULL, NULL, /* Lotsa these */
- 0, 0, 0, 0,
- WBENCHSCREEN
- };
-
- extern struct Window *w;
- static UWORD left=0, top=0;
-
- iconify()
- {
- UWORD width=icon.Width, height=icon.Height;
-
- windef.LeftEdge = left;
- windef.TopEdge = top;
- windef.Width = width;
- windef.Height = height;
-
- gadget.Flags = GADGHCOMP | GRELWIDTH | GRELHEIGHT | GADGIMAGE;
-
- if (!openstuff())
- return (0);
-
- return (1);
- }
-
- deiconify()
- {
- left = w->LeftEdge;
- top = w->TopEdge;
- closestuff();
- }
-
- static openstuff()
- {
- if(!(chipbitmap = (UWORD *)AllocMem((ULONG)sizeof(icon_data), MEMF_CHIP | MEMF_PUBLIC))) {
- puts("Can't allocate image bitmap");
- return FALSE;
- }
- CopyMem((char *)icon_data, (char *)chipbitmap, (int) sizeof(icon_data));
-
- /* copy the image structure too */
- if(!(chipimg = (struct Image *)AllocMem((ULONG)sizeof(icon), MEMF_CHIP | MEMF_PUBLIC))) {
- FreeMem(chipbitmap, (ULONG)sizeof(icon_data));
- puts("Can't allocate image structure");
- return FALSE;
- }
- CopyMem((char *)&icon, (char *)chipimg, (int) sizeof(icon));
- chipimg->ImageData = chipbitmap;
- gadget.GadgetRender = (APTR)chipimg;
- if (!(w = OpenWindow(&windef)))
- return (0);
- w->UserData = (BYTE *)ICON;
- return (1);
- }
-
- static closestuff ()
- {
- FreeMem(chipimg, (ULONG)sizeof(icon));
- FreeMem(chipbitmap, (ULONG)sizeof(icon_data));
- if(w)
- CloseWindow(w);
- }
-
-
-